<?php
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.view');
class DocarioViewEditcategory extends JView {
    function display($tpl = null) {
        $doc = JFactory::getDocument();
        $doc->addScript('components'.DS.'com_docario'.DS.'assets'.DS.'javascript'.DS.'categoryform.js');
        $doc->addStylesheet('components'.DS.'com_docario'.DS.'assets'.DS.'css'.DS.'docario.css');
    
        JToolBarHelper::title(JText::_('EDIT_CATEGORY'));
        JToolBarHelper::save();
        JToolBarHelper::back();
    
        $id = JRequest::getVar('cid');
        
        $model = $this->getModel();
        $model->setId($id);
        $category = $model->getCategory();
        $categories = $model->getCategories();
        
        $group_model = $this->getModel('group');
        if ($id) {
            $groups = $group_model->getGroupsCategory($category->id);
            
            foreach($groups as $group) {
                if (($group->read == 0) or ($group->read == '')) 
                    $group->css_read = 'permoff';
                else if($group->read == 1) $group->css_read = 'permon';
                
                if (($group->write == 0) or ($group->write == ''))
                    $group->css_write = 'permoff';
                else if ($group->write == 1) $group->css_write = 'permon';                
            }
            
            $this->assignRef('groups', $groups);
        }
        $users = $group_model->getJUsers();
        
        $this->assignRef('category', $category);
        $this->assignRef('users', $users);
        $this->assignRef('categories', $categories);
    
        parent::display($tpl);
    }
}
?>
